<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>3.模板字面量嵌套使用技巧</title>
  <style>
    * {
      padding: 0;
      margin: 0;
    }
    ul {
      list-style: none;
    }
    li:nth-child(odd) {
      background-color: aquamarine;
      color: white;
      padding: 10px;
    }
  </style>
</head>

<body>
  <script>
    let data = [
      { title: "sdfasdfaowefaef" },
      { title: "dshoasdf阿斯顿发生" },
      { title: "soisdfaoei" }
    ];

    console.log(data.map((item) => item.title).join(" "));
    function template () {
        return `<ul>
      ${data.map((item) => `
          <li>${item.title}</li>
      `).join('')}
  </ul>`;
      }
   // document.write(`${template()}`);
    document.body.innerHTML = template();  
  </script>
</body>

</html>